package io.lkt.modules.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.lkt.common.utils.PageUtils;
import io.lkt.common.utils.Query;
import io.lkt.commons.dynamic.datasource.annotation.DataSource;
import io.lkt.modules.sys.dao.BArticleInfoDao;
import io.lkt.modules.sys.dao.BPunchClockArticleInfoDao;
import io.lkt.modules.sys.entity.BArticleInfoEntity;
import io.lkt.modules.sys.entity.BPunchClockArticleInfoEntity;
import io.lkt.modules.sys.entity.BUserPunchClockInfoEntity;
import io.lkt.modules.sys.service.BPunchClockArticleInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.List;
import java.util.Map;


@Service("bPunchClockArticleInfoService")
public class BPunchClockArticleInfoServiceImpl extends ServiceImpl<BPunchClockArticleInfoDao, BPunchClockArticleInfoEntity> implements BPunchClockArticleInfoService {
    @Autowired
    private BPunchClockArticleInfoDao bPunchClockArticleInfoDao;

    @Override
    public List<BPunchClockArticleInfoEntity> queryList(Map<String, Object> params) {
        return bPunchClockArticleInfoDao.queryList(params);
    }

    @Override
    public int queryTotal() {
        return bPunchClockArticleInfoDao.queryTotal();
    }

    @Override
    public List<BUserPunchClockInfoEntity> getUserPunchClockInfo(Map<String, Object> params) {
        return bPunchClockArticleInfoDao.getUserPunchClockInfo(params);
    }

    @Override
    public int getUserPunchClockTotal(Map<String, Object> params) {
        return bPunchClockArticleInfoDao.getUserPunchClockTotal(params);
    }

    @DataSource("master")
    public BPunchClockArticleInfoEntity getById(Serializable id)
    {
        return (BPunchClockArticleInfoEntity)((BPunchClockArticleInfoDao)this.baseMapper).selectById(id);
    }

    /*@Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<BPunchClockArticleInfoEntity> page = this.page(
                new Query<BPunchClockArticleInfoEntity>().getPage(params),
                new QueryWrapper<BPunchClockArticleInfoEntity>()
//                        .apply("date_format (clock_article_time,'%Y-%m') >= date_format(now(),'%Y-%m')")
                        .apply("clock_article_time >= date_format(now(),'%Y-%m-%d')")
                        .orderByAsc("clock_article_time")
        );

        return new PageUtils(page);
    }*/

}
